def is_valid_brackets(sequence):
    stack = []
    opening_brackets = ['(', '[', '{', '<']
    closing_brackets = [')', ']', '}', '>']
    bracket_pairs = dict(zip(closing_brackets, opening_brackets))

    for char in sequence:
        if char in opening_brackets:
            stack.append(char)
        elif char in closing_brackets:
            if not stack or stack[-1] != bracket_pairs[char]:
                return False
            stack.pop()

    return len(stack) == 0

sequence = input("Введите скобочную последовательность: ")
print(is_valid_brackets(sequence))